#pragma once

#include "Particle.h"
#include "../SGD Wrappers/CSGD_TextureManager.h" // D3DCOLOR
#include <string>
#include <vector>
using namespace std;


class Emitter
{
	int maxParticles;
	vector<Particle> ParticleArray;
	string shape;
	bool isActive;
	float positionX;
	float positionY;
	float initialSpeedMin;
	float initialSpeedMax;
	float lifetimeMin;
	float lifetimeMax;
	float offsetX;
	float offsetY;
	int iclrA, iclrR, iclrG, iclrB;
	int fclrA, fclrR, fclrG, fclrB;
	float initialScale;
	float finalScale;
	float initialRotation;
	float finalRotation;
	float angleRange;
	float emitterRotation;
	int imageID;
	bool hasGravity;
	bool doesLoop;
	float spawnRate;
	string emitterName;
	float timesincespawn;
	int remainingparticles;

public:
	Emitter( string filepath, int maxParticles );
	~Emitter(void);


	////////////////////////////////////////////////////////
	////////// Mutators
	void SetShape( string shape );
	void SetActive( bool isActive );
	void SetPosX( float PosX );
	void SetPosY( float PosY );
	void SetSpeedMin( float SpeedMin );
	void SetSpeedMax( float SpeedMax );
	void SetLifetimeMin( float lifetimeMin );
	void SetLifetimeMax( float lifetimeMax );
	void SetOffsetX( float offsetX );
	void SetOffsetY( float offsetY );
	void SetInitClrA( int a ) { this->iclrA = a; }
	void SetInitClrR( int r ) { this->iclrR = r; }
	void SetInitClrG( int g ) { this->iclrG = g; }
	void SetInitClrB( int b ) { this->iclrB = b; }
	void SetFinalClrA( int a ) { this->fclrA = a; }
	void SetFinalClrR( int r ) { this->fclrR = r; }
	void SetFinalClrG( int g ) { this->fclrG = g; }
	void SetFinalClrB( int b ) { this->fclrB = b; }
	void SetInitialScale( float Scale );
	void SetFinalScale( float Scale );
	void SetInitialRotation( float angleofRotation );
	void SetFinalRotation( float angleofRotation );
	void SetAngleRange( float anglerange );
	void SetEmitterRotation( float angleofrotation );
	void SetImageID( int ID );
	void SetGravity( bool gravity ) { hasGravity = gravity; }
	void SetSpawnRate( float rate ) { spawnRate = rate; }
	void SetLooping( bool looping ) { doesLoop = looping; }
	void SetName( string name ) { emitterName = name; }


	//////////////////////////////////////////////////////
	///// Accsesors
	int GetImageID( void );
	string GetShape( void );
	tVector2D GetPosition( void );
	float GetOffsetX( void );
	float GetOffsetY( void );
	float GetEmitterRotation( void );
	float GetSpeedMin( void );
	float GetSpeedMax( void );
	float GetLifetimeMin( void );
	float GetLifetimeMax( void );
	int GetInitClrA( void ) { return iclrA; }
	int GetInitClrR( void ) { return iclrR; }
	int GetInitClrG( void ) { return iclrG; }
	int GetInitClrB( void ) { return iclrB; }
	int GetFinalClrA( void ) { return fclrA; }
	int GetFinalClrR( void ) { return fclrR; }
	int GetFinalClrG( void ) { return fclrG; }
	int GetFinalClrB( void ) { return fclrB; }
	float GetInitialScale( void );
	float GetFinalScale( void );
	float GetInitialRotation( void );
	float GetFinalRotation( void );
	float GetAngleRange( void );
	float GetSpawnRate( void ) { return spawnRate; }
	bool GetGravity( void ) { return hasGravity; }
	bool GetLooping( void ) { return doesLoop; }
	string GetName( void ) { return emitterName; }

	//Use This To Create Particle Array. Call Only after setting all emitter information.
	void ParticleInitialize( void );

	void Update(float deltaTime);
	void Render( void ) const;
};

